<template>
  <div>
    <div style="padding: 5px 10px">
      <h3>修订调整历史信息:</h3>

      <table class="bs-table" v-for="(item,index) in detaildata" :key="index" style="margin-top: 20px">
        <tr class="bs-table_row">
          <th class="bs-table_th" style="width: 200px">调整建议名称</th>
          <td class="bs-table_td" colspan="5">
            <span>{{item.pimRevise.reviseName}}</span>
          </td>
        </tr>
        <tr class="bs-table_row">
          <th class="bs-table_th" style="width: 200px">调整内容</th>
          <td class="bs-table_td" colspan="5">
            <span>{{item.pimRevise.content}}</span>
          </td>
        </tr>
        <tr class="bs-table_row">
          <th class="bs-table_th">相关附件</th>
          <td class="bs-table_td" colspan="5">
            <div v-for="(file,index) in item.pimRevise.contentFileIds" v-if="item.pimRevise.contentFileIds.length!=0" :key="index">
              <preview :attachementId="file" v-if="file"></preview>
            </div>
          </td>
        </tr>

        <!--历史流程信息-->
        <tr class="bs-table_row">
          <th class="bs-table_th" style="width: 140px">用户</th>
          <th class="bs-table_th" style="width: 140px">部门名称</th>
          <th class="bs-table_th" style="width: 100px">环节</th>
          <th class="bs-table_th">结果</th>
          <th class="bs-table_th" style="width: 200px">操作时间</th>
          <th class="bs-table_th" width="100px">转办历史</th>
        </tr>
        <tr class="bs-table_row" v-for="(record,index) in item.hisList" v-if="item.hisList.length!=0" :key="index">
          <th class="bs-table_td">{{record.assigneeNickname}}</th>
          <th class="bs-table_td">{{record.deptName}}</th>
          <th class="bs-table_td">{{record.taskName}}</th>
          <th class="bs-table_td">{{record.opinion}}</th>
          <th class="bs-table_td">{{record.date}}</th>
          <th class="bs-table_td">
            <div class="menu-title"
                 v-if="record.taskAssigneeHisList!=null&&record.taskAssigneeHisList.length!=0">
              <el-button size="mini"
                         type="warning"
                         @click.stop="taskAssigneeHisView(record.taskAssigneeHisList)">转办历史</el-button>
            </div>
            <div v-else>
              <p>无</p>
            </div>
          </th>
        </tr>
        <tr v-if="item.hisList.length==0"
            style="text-align: center;font-size: 18px;color: #3333;height: 100px;line-height: 100px;">
          <th class="bs-table_td" colspan="5">
            暂无数据
          </th>
        </tr>
      </table>
      <!--  没有消息-->
      <div v-if="!hasReviseHisList"
           style="text-align: center;font-size: 18px;color: #3333;height: 260px;line-height: 260px;">
        暂无数据
      </div>
    </div>
    <assign-history :visible="assignHisVisible"
                    :taskAssigneeHisList="taskAssigneeHisList"
                    @cancelAssignHis="cancelAssignHis"></assign-history>
  </div>
</template>

<script>
  import {getReviseDetail} from "@/api/achievement";

  export default {
    name: "reviseDetailPage",
    props: {
      id: Number
    },
    created() {
      this.getReviseDetailData();
    },
    computed: {},
    data() {
      return {
        detaildata: {},
        hasReviseHisList: false,
        assignHisVisible:false,
        taskAssigneeHisList:[],
      }
    },
    methods: {
      getReviseDetailData() {
        getReviseDetail(this.id).then(response => {
          if (response.data.code == 0) {
            if (response.data.data.length == 0) {
              this.hasReviseHisList = false;
            } else {
              this.hasReviseHisList = true;
            }
            this.detaildata = response.data.data;
          }
        });
      },
      taskAssigneeHisView(taskAssigneeHisList){
        this.assignHisVisible = true;
        this.taskAssigneeHisList = taskAssigneeHisList
      },
      cancelAssignHis(){
        this.assignHisVisible = false;
      }
    }
  }
</script>

<style ang="scss" scoped>

</style>
